//
//  UIUitls.swift
//  swfitTest
//
//  Created by hncy on 2022/7/4.
//

import UIKit


class UIUtils {
    static func getControllerFromStoryboard(name: String, vc:String) -> UIViewController {
        let storyBoard:UIStoryboard! = UIStoryboard(name: name, bundle: nil)
        
        let controller = storyBoard!.instantiateViewController(withIdentifier: vc)
        
        return controller
    }
    
    static func getControllerFromMain(name: String) -> UIViewController {
        let storyBoard:UIStoryboard! = UIStoryboard(name: "Main", bundle: nil)
        
        let controller = storyBoard!.instantiateViewController(withIdentifier: name)
        
        return controller
    }
    
    
    static func presentUserController(parent: UIViewController ) -> UIViewController {
        let storyBoard:UIStoryboard! = UIStoryboard(name: "User", bundle: nil)
        let controller = storyBoard!.instantiateViewController(withIdentifier: "UserNavigationController")
        
        controller.modalPresentationStyle = . fullScreen
        controller.modalTransitionStyle = .crossDissolve
        parent.present(controller, animated: true)
        
        return controller
    }
    
    static func pushViewController(parent: UIViewController,vc:UIViewController,needLogin:Bool = false)  {
        if needLogin {
            self.presentUserController(parent: parent)
        }else {
            parent.navigationController?.pushViewController(vc, animated: true)
        }
    }
    
}
